<template>
    <div class="cell-item">
        <div class="left" :style="position == 'right' ? 'justify-content: space-between;padding-right: 6px;' : ''">
            <div class="image" v-if="item.image_url">
                <van-image
                    width="50"
                    height="50"
                    :src="item.image_url"
                    fit="contain"
                />
            </div>
            <div class="title" v-if="item.title">{{item.title}}</div>
            <div class="title" v-if="item.name">{{item.name}}</div>
            <div class="value" v-if="item.value">{{item.value}}</div>
        </div>
        <div class="right" v-if="is_arrows"><i class="iconfont icon-youjiantou"></i></div>
    </div>
</template>

<script lang="ts" setup>
import type { CellItem } from '@/types/global'

withDefaults(defineProps<{
    item?: CellItem,
    is_arrows?: boolean
    position?: string
}>(), {
    item: () => {
        return {
            title: 'title',
            image_url: 'src/assets/images/my_avatar.png',
            value: 'value',
        }
    },
    is_arrows: true,
    position: 'left'
})
</script>

<style scoped lang="scss">
.cell-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #fff;
    border-bottom: 1px solid #ececec;
    padding: 15px 10px;
    .left {
        flex: 1;
        display: flex;
        align-items: center;
        .image {
            width: 50px;
            height: 50px;
            border-radius: 5px;
            overflow: hidden;
            margin-right: 10px;
        }
        .title {
            font-size: 16px;
            color: #000;
        }
        .value {
            padding-left: 15px;
            color: #9b9999;
            font-size: 13px;
            justify-content: flex-end;
            line-height: 22px;
            flex: 1;
            display: flex;
        }
    }
    .right {
        width: 20px;
        .iconfont {
            font-size: 14px;
            color: #9b9999;
        }
    }
}
</style>